/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package edu.uts.reekie.designer.edit;

import org.eclipse.draw2d.Connection;
import org.eclipse.draw2d.ConnectionAnchor;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.PolylineConnection;

import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.LayerConstants;
import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.requests.CreateConnectionRequest;
import org.eclipse.gef.requests.ReconnectRequest;

import edu.uts.reekie.designer.conceptual.model.*;
import edu.uts.reekie.designer.figures.FigureFactory;
import edu.uts.reekie.designer.figures.NodeFigure;
import edu.uts.reekie.designer.model.*;
import edu.uts.reekie.designer.model.commands.OldConnectionCommand;


/*
 * 
 * TODO: delete, keep only for reference maybe
 */
public abstract class LogicNodeEditPolicy
	extends org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy
{

	/*
protected Connection createDummyConnection(Request req) {
	PolylineConnection conn = FigureFactory.createNewWire(null);
	return conn;
}

protected Command getConnectionCompleteCommand(CreateConnectionRequest request) {	
	OldConnectionCommand command = (OldConnectionCommand)request.getStartCommand();
	command.setTarget(getLogicSubpart());
	ConnectionAnchor ctor = getLogicEditPart().getTargetConnectionAnchor(request);
	if (ctor == null)
		return null;
	//command.setTargetTerminal(getLogicEditPart().mapConnectionAnchorToTerminal(ctor));
	return command;
}

protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
	OldConnectionCommand command = new OldConnectionCommand();
	//command.setWire(new Wire());
	command.setSource(getLogicSubpart());
	ConnectionAnchor ctor = getLogicEditPart().getSourceConnectionAnchor(request);
	//command.setSourceTerminal(getLogicEditPart().mapConnectionAnchorToTerminal(ctor));
	request.setStartCommand(command);
	return command;
}


protected IFigure getFeedbackLayer() {
	
	return getLayer(LayerConstants.SCALED_FEEDBACK_LAYER);
}



protected LogicEditPart getLogicEditPart() {
	return (LogicEditPart) getHost();
}

protected ViewSubpart getLogicSubpart() {
	return (ViewSubpart) getHost().getModel();
}

protected Command getReconnectTargetCommand(ReconnectRequest request) {
	if (getLogicSubpart() instanceof LiveOutput || 
		getLogicSubpart() instanceof GroundOutput)
			return null;
	
	OldConnectionCommand cmd = new OldConnectionCommand();
	//cmd.setWire((Wire)request.getConnectionEditPart().getModel());

	ConnectionAnchor ctor = getLogicEditPart().getTargetConnectionAnchor(request);
	cmd.setTarget(getLogicSubpart());
	//cmd.setTargetTerminal(getLogicEditPart().mapConnectionAnchorToTerminal(ctor));
	return cmd;
}

protected Command getReconnectSourceCommand(ReconnectRequest request) {
	OldConnectionCommand cmd = new OldConnectionCommand();
//	cmd.setWire((Wire)request.getConnectionEditPart().getModel());

	ConnectionAnchor ctor = getLogicEditPart().getSourceConnectionAnchor(request);
	cmd.setSource(getLogicSubpart());
	//cmd.setSourceTerminal(getLogicEditPart().mapConnectionAnchorToTerminal(ctor));
	return cmd;
}

protected NodeFigure getNodeFigure() {
	return (NodeFigure)((GraphicalEditPart)getHost()).getFigure();
}*/

}
